// ml:run = $bin < input
// ml:opt = 0
// ml:ccf += -g
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

struct edge
{
    long long to, cost;
};

struct data
{
    long long now, len, tim;
};

long long const maxn = 5007;
long long n, m, t;
long long max;
std::vector<long long> ans;
std::vector<std::vector<edge>> graph;
long long f[maxn][maxn];
long long from[maxn][maxn];

void add_edge(long long u, long long v, long long c)
{
    graph[u].push_back({v, c});
}

void dfs(long long u, long long len, long long cost)
{
    if (cost >= t) return;
    for (auto &e : graph[u]) {
        long long v = e.to, c = e.cost;
        if ((f[v][len + 1] && f[v][len + 1] > cost + c) || !f[v][len + 1]) {
            f[v][len + 1] = cost + c;
            from[v][len + 1] = u;
            dfs(v, len + 1, cost + c);
        }
    }
}

void print(long long len)
{
    std::vector<long long> ans;
    long long now = n;
    ans.push_back(now);
    do {
        now = from[now][len];
        len--;
        ans.push_back(now);
    } while (now != 1);
    std::cout << ans.size() << "\n";
    for (long long i = ans.size() - 1; i >= 0; i--) std::cout << ans[i] << " ";
    std::cout << "\n";
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin >> n >> m >> t;
    graph.resize(n + 1);
    for (long long i = 0; i < m; i++) {
        long long u, v, c; std::cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    dfs(1, 1, 0);
    for (long long i = n; i >= 2; i--) {
        if (f[n][i] && f[n][i] <= t) {
            print(i);
            break;
        }
    }
}

